<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match='nbsp' name='nbsp'>
<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
</xsl:template>

<xsl:template match="Registration">

<!-- Insert appropriate Validation -->
<script>
function validateForm() {
	document.returnValue = true;
	if ( (document.getElementById("T3").value) == '' ) {
		alert("Devi mettere un oggetto al tuo messaggio !");
		document.returnValue = false;
	}else{
	  if ( (document.getElementById("TA4").value) == '' ) {
  		alert("Devi mettere un contenuto nel messaggio!");
  		document.returnValue = false;
  	}
  }
}
</script>

<!-- End of Insert appropriate Validation -->


<table class="gbox" border="0" cellspacing="4" cellpadding="0" width="100%">
<form name="formRegistration" method="post" action="{@action}" onSubmit="validateForm();return document.returnValue">
<tr>
<input type="hidden" name="FORM_ID" value="FORM5"></input>
<input type="hidden" name="staff" value="{/Registration/@staff}"></input>
<input type="hidden" name="msgid" value="{/Registration/@msgid}"></input>
<input type="hidden" name="type" value="{/Registration/@type}"></input>
<input type="hidden" name="activityid" value="{/Registration/@activityid}"></input>
<input type="hidden" name="lid" value="{/Registration/@lid}"></input>
<input type="hidden" name="holidayid" value="{/Registration/@holidayid}"></input>
<input type="hidden" name="senderIP" value="{/Registration/@senderIP}"></input>

<td colspan="4">
</td>
</tr>

<xsl:apply-templates/>

</form>

</table>

</xsl:template>


<xsl:template match="Question">


  <xsl:if test="@ID=1">
			<tr height="30px">
				<td valign="top">
				<xsl:value-of select="@Description"/>
				</td>

				<td></td>

				<td colspan="2" align="left" valign="top">
				<input value="{/Registration/@senderNick}" type="text" name="{concat('T',@ID)}" size="{@P2}" maxlength="{@P1}" readonly="true">
				</input>
				<br/>
				<span class="body_10px_red">
				<b>Sender IP address:
				<xsl:value-of select="/Registration/@senderIP"/>
				</b></span><br/>
				</td>
			</tr>
	</xsl:if>

  <xsl:if test="@ID=2">
			<tr height="30px">
				<td valign="top">
				<xsl:value-of select="@Description"/>
				</td>
				<td></td>
				<td colspan="2" align="left" valign="top">


				<select class="body" size="1" name="D{@ID}">
					<xsl:for-each select="Answer[(floor( @Use div 2 ) mod 2) or (/Registration/@activityid &gt; 0 and floor( @Use div 4 ) mod 2)]">
						<xsl:choose>
							<xsl:when test='/Registration/@destid=@ID'>
							  <option selected="select" value="{@ID}"><xsl:value-of select="."/></option>
							</xsl:when>
							<xsl:otherwise>
							  <option value="{@ID}"><xsl:value-of select="."/></option>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
				</select>

				<br/><span class="body_10px_red"><xsl:value-of select="@Comment"/></span>
				</td>
			</tr>
	</xsl:if>

	<xsl:if test="@ID=3">
			<tr>
				<td valign="top">
				<xsl:value-of select="@Description"/>
				</td>
				<td></td>
				<td colspan="2" align="left" valign="top">
				<xsl:choose>
					<xsl:when test='/Registration/@subject=""'>
							<input type="text" name="T{@ID}" size="{@P2}" maxlength="{@P1}"></input>
					</xsl:when>
					<xsl:otherwise>
						<input value="{/Registration/@subject}" type="text" name="T{@ID}" size="{@P2}" maxlength="{@P1}"></input>
					</xsl:otherwise>
				</xsl:choose>
				<br/><span class="body_10px_red"><xsl:value-of select="@Comment"/></span>
				</td>
			</tr>
	</xsl:if>

	<xsl:if test="@ID=4">
			<tr>
				<td valign="top">
				<xsl:value-of select="@Description"/>
				</td>
				<td ></td>
				<td colspan="2" align="left" valign="top">

				<TEXTAREA id="TA{@ID}" name="TA{@ID}" rows="{@P1}" cols="{@P2}" WRAP="SOFT" style="width:100%;">
				<xsl:if test='/Registration/@body!=""'>
				  <xsl:value-of select="/Registration/@body"/>
				</xsl:if>
				</TEXTAREA>

				<br/><span class="body_10px_red"><xsl:value-of select="@Comment"/></span>
				</td>
			</tr>
	</xsl:if>

	<xsl:if test="@ID=5">
		<tr><td colspan="4" align="center">

		<br/>
		<input type="submit" name="{concat('SUBMIT',@ID)}" value="{@Description}" ></input>
		<br/>
		</td>
		</tr>
	</xsl:if>


</xsl:template>

</xsl:stylesheet>